package com.wsc.entity;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "t_teachers")
@AllArgsConstructor
@NoArgsConstructor
@Data
//教师表关联科室表
public class Teacher {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	// 教师编号
	private Integer id;
	// 卡号 @Column(unique=true)指这个字段的值在这张表里不能重复，所有记录值都要唯一，就像主键那样;
	@Column(unique=true)
	private String cardno;
	// 教师姓名
	private String name;
	// 教师性别
	private String sex;
	// 科室编号
	private Integer sectionid;
	// 状态 0 正常 >0 所在阅览室id
	private Integer status;
	// 备注
	private String remark;
	// id cardno name sex sectionid status remark
	@ManyToOne(targetEntity = Section.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	// 外键列 关联表的主键列
	@JoinColumn(name = "sectionid", referencedColumnName = "id", insertable = false, updatable = false)
	private Section section;
}
